#ifndef HHFLOODFILL
#define HHFLOODFILL

#include <QPoint>
#include <QStack>
#include <QDebug>
#include <QWidget>
#include <QPixmap>
#include <QColor>
#include <QMouseEvent>
#include <QImage>
#include <QBitmap>

namespace Ui {
class HHFloodFill;
}

class HHFloodFill : public QWidget
{
    Q_OBJECT

public:
    explicit HHFloodFill(QWidget *parent = 0);
    ~HHFloodFill();

    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);

    void ScanLineSeedFill(int x, int y, QColor new_color, int iThresHold);
    void SearchLineNewSeed(QStack<QPoint>& stk, int xLeft, int xRight,
    int y, QColor new_color, int iThresHold);

    int FillLineRight(int x, int y, QColor new_color, int iThresHold);
    int FillLineLeft(int x, int y, QColor new_color, int iThresHold);
    int SkipInvalidInLine(int xt, int y, int xRight, QColor new_color, int iThresHold);

    bool checkColorIsOutBorder(const QColor& refColor, const QColor& targetColor, const double& dThresHold);

private slots:
    void on_pushButton_clicked();


private:
    Ui::HHFloodFill *ui;

    QString             m_strPath;
    QImage              m_image;
    QImage              m_resultImage;

    bool                m_bPressed;
    QPoint              m_pressedPos;
};


#endif // HHFLOODFILL
